<template>
	<view class="message" >
			<view class="message-list">
				<!-- <view v-for="(item,index) in list" :key="index"> -->
					
					<view v-for="(item,index) in list" :key="index" class="item-info">
						<view class="title"> {{item.contact || ''}} </view>
						<view class="text"> 联系方式：{{item.contactPhone || ''}} </view>
						<view class="text"> 部门：{{item.deptName || ''}} </view>
						<view class="text"> 申请时间：{{item.updateTime || item.createTime}} </view>
						<view class="text"> 处理状态：
							<!-- //是否处理 0未处理1同意2驳回 -->
							<view class="status status1" v-if="item.status == '0'">未处理</view>
							<view class="status status2" v-if="item.status == '1'">同意</view>
							<view class="status status3" v-if="item.status == '2'">驳回</view>
							<view class="status status3" v-if="item.status == '3'">已撤销</view>
						</view>
						<view class="text" v-if="item.status == '1'"> 签约状态：
							<view class="status status1" v-if="item.isSign == '0'">未签约</view>
							<view class="status status2" v-if="item.isSign == '1'">已签约</view>
						</view>
						<view class="text" v-if="item.status == '2'"> 驳回原因：{{item.reason || '无'}} </view>
						<view class="btn-box">
							<view class="btn" @click="revocation(item.id)" v-if="item.status == '0'">
								撤销
							</view>
							<view class="btn btn1"  @click="toUrl(item)" v-if="item.status == '0' || item.status == '2'">
								修改
							</view>
						</view>
						
					</view>
				<!-- </view> -->
			</view>
			<uni-load-more :status="status_load"></uni-load-more>
		<!-- <Tabbar index="3"></Tabbar> -->
		
	</view>
</template>

<script>
	import Tabbar from "@/components/Tabbar/index.vue";

	import {
		myApplicationList,
		updateApplication
	} from "@/api";
	export default {
		components: {
			Tabbar,
		},
		data() {
			return {
				downOption: {
					auto: false //是否在初始化后,自动执行downCallback; 默认true
				},
				list:[],
				status_load: 'more',
				queryParams:{
					deptId:'',
					pageNum: 1,
					pageSize: 10,
				},
			
			};
		},	
		onLoad(params) {
			this.queryParams.pageNum = 1
			this.queryParams.deptId = params.deptId || ''
		},
		onShow() {
			this.queryParams.pageNum = 1
			this.list = []
			this.getList()
		},
		methods: {
			getList(){
				myApplicationList(this.queryParams).then(res => {
					uni.hideLoading()
					let data = res.data.records
					if (data) {
						this.list = this.list.concat(data)
					}
					if (this.queryParams.pageSize == data.length) {
						this.queryParams.pageNum += 1;
						this.status_load = 'more'
					} else {
						this.status_load = 'noMore'
					}
				})
			},
			toUrl(item){
				this.$route({
					url: '/pages/member/index',
					params: { data: JSON.stringify(item) },
				})
			},
			// 撤销
			revocation(id){
				updateApplication({
					id:id,
					status:3
				}).then((res) => {
				  this.$toast("成功");
				  this.queryParams.pageNum = 1
				  this.list = []
				  this.getList()
				});
			}
			
		}
		
	};
</script>

<style lang="less" scoped>
	.qinayue{
		width: 100vw;
		height: 100vh;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.message {
		.tabs {
			position: fixed;
			top: 0;
			left: 0;
			right: 0;
			background: #fff;
			z-index: 99;
		}

		.message-list {
			padding: 30rpx;
		}

		.item-time {
			margin-bottom: 20rpx;
		}

		.item-info {
			margin-bottom: 30px;
			padding: 30rpx;
			background: #fff;
			border-radius: 12rpx;
			.title {
				font-size: 30rpx;
				color: #000000;
				position: relative;
				display: inline-block;
			}
			.text{
				font-size: 28rpx;
				color: #666668;
				margin-top: 10rpx;
				display: flex;
				.status{
					font-size: 28rpx;
					&.status1{
						color:#FC880C;
					}
					&.status2{
						color:#138E57;
					}
					&.status3{
						color:#DF0E0E;
					}
				}
			}
			.btn-box{
				display: flex;
				margin-top: 30rpx;
				.btn {
					width: 200rpx;
					height: 60rpx;
					border-radius: 40rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 28rpx;
					color: #FFFFFF;
					line-height: 60rpx;
					text-align: center;
					background: #F7F7F7;
					border: 2rpx solid #138E57;
					
					color: #138E57;
					&.btn1 {
						background: linear-gradient(83deg, #48B453 0%, #2C9F79 100%);
						border: 2rpx solid #138E57;
						color: #fff;
						margin-left: 20rpx;
					}
				}
			}
			
			
			
		}
	}
</style>